import 'package:flutter/widgets.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

// 提示
class SzEasyLoading {
  //loading
  static show({
    String? status,
    Widget? indicator,
    EasyLoadingMaskType? maskType = EasyLoadingMaskType.clear,
    bool? dismissOnTap,
  }) {
    dismiss();
    EasyLoading.show(
      status: status,
      indicator: indicator,
      maskType: maskType = EasyLoadingMaskType.clear,
      dismissOnTap: dismissOnTap,
    );
  }

  //toast
  static showToast(
    String status, {
    Duration? duration = const Duration(milliseconds: 500),
    EasyLoadingToastPosition? toastPosition,
    EasyLoadingMaskType? maskType = EasyLoadingMaskType.black,
    bool? dismissOnTap,
  }) {
    dismiss();
    EasyLoading.showToast(
      status,
      duration: duration,
      toastPosition: toastPosition,
      maskType: maskType,
      dismissOnTap: dismissOnTap,
    );
  }

  //进度 提示  value[0-1]
  static showProgress(
    double value, {
    String? status,
    EasyLoadingMaskType? maskType = EasyLoadingMaskType.clear,
  }) {
    dismiss();
    EasyLoading.showProgress(value, status: status, maskType: maskType);
  }

  //成功提示
  static showSuccess(
    String status, {
    Duration? duration,
    EasyLoadingMaskType? maskType = EasyLoadingMaskType.clear,
    bool? dismissOnTap,
  }) {
    dismiss();
    EasyLoading.showSuccess(
      status,
      duration: duration,
      maskType: maskType,
      dismissOnTap: dismissOnTap,
    );
  }

  //警告 提示
  static showInfo(
    String status, {
    Duration? duration,
    EasyLoadingMaskType? maskType = EasyLoadingMaskType.clear,
    bool? dismissOnTap,
  }) {
    dismiss();
    EasyLoading.showInfo(
      status,
      duration: duration,
      maskType: maskType,
      dismissOnTap: dismissOnTap,
    );
  }

//失败提示
  static showError(
    String status, {
    Duration? duration,
    EasyLoadingMaskType? maskType = EasyLoadingMaskType.clear,
    bool? dismissOnTap,
  }) {
    dismiss();
    EasyLoading.showError(
      status,
      duration: duration,
      maskType: maskType,
      dismissOnTap: dismissOnTap,
    );
  }

  //关闭
  static dismiss({
    bool animation = true,
  }) {
    EasyLoading.dismiss(animation: animation);
  }
}
